package com.lalifa.googledate.ui.activity.login

import com.drake.net.utils.scopeNetLife
import com.lalifa.base.BaseActivity
import com.lalifa.extension.isEmail
import com.lalifa.extension.onClick
import com.lalifa.extension.start
import com.lalifa.extension.text
import com.lalifa.extension.toast
import com.lalifa.googledate.R
import com.lalifa.googledate.databinding.ActivityRegisterBinding

class RegisterActivity : BaseActivity<ActivityRegisterBinding>() {
    override fun getViewBinding() = ActivityRegisterBinding.inflate(layoutInflater)

    override fun initView() {

    }

    override fun onClick() {
        super.onClick()
        binding.apply {
            back.onClick {
                finish()
            }
            register.onClick {
                val etEmail = etEmail.text()
                val etName = etName.text()
                val etPass = etPass.text()
                val etPass1 = etPass1.text()
                if (etEmail.isEmpty()) {
                    toast(getString(R.string.place_input_email))
                    return@onClick
                }
                if (!etEmail.isEmail()) {
                    toast(getString(R.string.place_input_email_right))
                    return@onClick
                }
                if (etName.isEmpty()) {
                    toast(getString(R.string.place_input_name))
                    return@onClick
                }
                if (etPass.isEmpty()) {
                    toast(getString(R.string.place_input_pass))
                    return@onClick
                }
                if (etPass1.isEmpty()) {
                    toast(getString(R.string.place_input_pass1))
                    return@onClick
                }
                if (etPass != etPass1) {
                    toast(getString(R.string.place_input_pass2))
                    return@onClick
                }
            }
        }
    }
}